<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 练习:单击时触发单击事件， 双击时只触发双击事件 -->
<!-- BOM:setTimeOut() -->
    <button id="btn">huhu</button>


    <script>
    var btn=document.getElementById('btn')
    btn.addEventListener('click',fn);
    btn.addEventListener('dblclick',fn1);
    var num=0;
    function fn() {
        num=0;
        // btn.removeEventListener('click',fn);
        st = setTimeout(ff,230);
    }
    function ff(){
        if(num==0){
            alert('2班');
        }
        clearTimeout(st);
    }
    function fn1() {
        num++;
        alert('4班');
    }
    </script>
</body>
</html>